/*自定义--校区管理*/
import { routerRedux } from 'dva/router';
import * as LoginService from '../services/basics';

export default {
  namespace: 'signin',
  state: {
    data: [],
  },
  effects: {
     //默认查询
    *fetch_Sign({ payload }, { call, put }) {
      	const response = yield call(LoginService.get,'/api/web/signinConfig/getSigninConfigList',payload); 
    	yield put({type: 'save',payload: response.data.obj});
    },
    //新增
    *addsign({ payload, callback }, { call, put }) {
      const response = yield call(LoginService.get,'/api/web/signinConfig/insertSigninConfig', payload);
      callback(response.data.res,response.data.resMsg);
     	yield put({type:'fetch_Sign'});
    },
    //修改
    *updatesign({ payload, callback }, { call, put }) {
      const response = yield call(LoginService.get,'/api/web/signinConfig/updateSigninConfig', payload);
      callback(response.data.res,response.data.obj);
     	yield put({type:'fetch_Sign'});
    },
    //删除
    *slesign({ payload, callback }, { call, put }) {
      const response = yield call(LoginService.get,'/api/web/signinConfig/deleteSigninConfigs', payload);
      callback(response.data.res,response.data.obj);
     	yield put({type:'fetch_Sign'});
    },
    //签到扫码
     *addsignss({ payload, callback }, { call, put }) {
      const response = yield call(LoginService.get,'/api/web/signin/insertSignin', payload);
      callback(response.data.res,response.data.resMsg);
     	yield put({type:'fetch_Sign'});
    },
    
  },

  reducers: {
    save(state, action) {
      return {
        ...state,
        data: action.payload,
      };
    },
  },
};
